package com.asset.dispoal.commom.version.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.strategy.AbstractStrategyManager;
import tech.mhuang.pacebox.core.util.ObjectUtil;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

/**
 * @author qr
 * @date 2022/2/18$
 */
@Component
public class VersionStrategyManager extends AbstractStrategyManager<String, String> {

    @Autowired
    Map<String, VersionStrategyServer> strategyServerMap = new HashMap<>();

    @Override
    @PostConstruct
    public void init() {
        for (Map.Entry<String, VersionStrategyServer> entry : strategyServerMap.entrySet()) {
            VersionStrategyServer caseTypeStrategyServer = entry.getValue();
            if (ObjectUtil.isEmpty(caseTypeStrategyServer.event())) {
                continue;
            }
            caseTypeStrategyServer.event().forEach(event -> set(event, caseTypeStrategyServer));
        }
    }
}
